package com.pep.mgmt.util;

import java.util.Date;

import org.springframework.http.HttpStatus;

import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Data;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Result<T>  {

    private Integer status;
    private String message;
    private T data;

    private Date timestamp;

    public static <T> Result<T> result(Integer status, String msg, T data) {
        Result<T> r = new Result<>();
        r.setStatus(status);
        r.setMessage(msg);
        r.setData(data);
        r.setTimestamp(new Date());
        return r;
    }

    public static <T> Result<T> error(Integer code, String msg, T data) {
        return result(code, msg, data);
    }

    public static <T> Result<T> success(String msg, T data) {
        return result(HttpStatus.OK.value(), msg, data);
    }

}